package com.edu.study.controller;

import com.edu.study.service.EduWordService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * 单词相关接口
 */
@Api(tags = "12、单词接口")
@RestController
@RequestMapping("/api/word")
public class WordController extends BaseController {

  @Autowired
  EduWordService eduWordService;

  /**
   * 获取用户所有课程单词
   */
  @GetMapping(value = "/getUserCourseWords")
  @ApiOperation(value = "获取用户所有课程单词")
  public AjaxResult getUserCourseWords(
      @RequestParam(defaultValue = "1") int pageNum,
      @RequestParam(defaultValue = "10") int pageSize
  ) {
    // 在controller层获取分页参数，传递到service
    PageDomain pageDomain = TableSupport.buildPageRequest();
    return AjaxResult.success(eduWordService.getUserCourseWords(pageDomain.getPageNum(), pageDomain.getPageSize()));
  }

}
